package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.service.OrderService;
import org.springframework.web.bind.annotation.*;

/**
 * []
 *
 * @author : [mhr]
 * @version : [v1.0]
 * @createTime : [2025/2/12 17:22]
 */

@RestController
@RequestMapping("orderList")
public class OrderListController {

    @Reference
    private OrderService orderService;

    @GetMapping("/findPage")
    public PageResult findPage(QueryPageBean queryPageBean) throws Exception {
        return  orderService.findAll(queryPageBean);
    }

    @GetMapping
    public Result edit(Integer id) throws Exception {

        try {
            orderService.edit(id);
            return new Result(true, MessageConstant.EDIT_ORDER_SUCCESS);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.EDIT_ORDER_FAIL);
        }
    }

}
